package com.smartens.boit.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.smartens.boit.fragment.AutoControlFragment;
import com.smartens.boit.fragment.ManualControlFragment;

/**
 * @Description 带tab适配器
 * @Author songtt
 * @Date 2021/3/4
 */

public class FaultTableViewAdapter extends FragmentPagerAdapter {
    private String[] mTitles ;

    public FaultTableViewAdapter(@NonNull FragmentManager fm, String[] title) {
        super(fm);
        this.mTitles = title;
    }


    @NonNull
    @Override
    public Fragment getItem(int position) {
        if (position == 1) {
            return new AutoControlFragment();
        }
        return new ManualControlFragment();
    }

    @Override
    public int getCount() {
        return mTitles.length;
    }

    /**
     * ViewPager与TabLayout绑定后，这里获取到PageTitle就是Tab的Text
     * @param position
     * @return
     */
    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles[position];
    }
}
